/**
 * @summary plug
 */
import { Express } from 'express-serve-static-core';
import { indexApi, indexJwtSignApi, indexSocketApi, indexXlsxApi, indexUploadApi, indexUploadHtmlApi, indexPhaserDemo } from '../api/index';
import UtilsIndex from '../../utils/index';

/**
 * @class 路由注册
 */
class RoutesIndex extends UtilsIndex {
    constructor() {
        super();
    }
    protected routerUse(callback: (e: string) => void, _app: Express): void {
        try {
            _app.use('/', this.jwtUse(), indexApi);
            _app.use('/indexJwtSignApi', indexJwtSignApi);
            _app.use('/indexSocketApi', indexSocketApi);
            _app.use('/indexXlsxApi', indexXlsxApi);
            _app.use('/indexUploadApi', indexUploadApi);
            _app.use('/indexUploadHtmlApi', indexUploadHtmlApi);
            _app.use('/indexPhaserDemo', indexPhaserDemo);
        } catch (error) {
            callback(error);
        }
        callback('check routes ok');
    }
    private jwtUse() {
        return this.jwt();
    }
}

export default RoutesIndex;